#include <cstdio>

int const maxn = 300100;
int da[2 * maxn];
int n;

void print(int p)
{
	std::printf("%d", da[p]);
	for (int i = 1; i < n; i++) std::printf(" %d", da[p + i]);
	std::printf("\n");
}

int min_representation()
{
	int i = 0, j = 1;
	for (int t; i < n && j < n; ) {
		if (da[i] < da[j]) j++;
		else if (da[j] < da[i]) i = j, j++;
		else {
			for (t = 0; t < n; t++)
				if (da[t + i] < da[t + j]) { j += t; break; }
				else if (da[t + j] < da[t + i]) { i = j; j = (j + t) % n; break; }
			if (t == n) break;
		}
	}
	return i;
}

int main()
{
	std::scanf("%d", &n);
	for (int i = 0; i < n; i++) { std::scanf("%d", &da[i]); da[i + n] = da[i]; }

	print(min_representation());
}

